module.exports = {
  testEnvironment: 'jsdom',
  moduleFileExtensions: ['js', 'jsx', 'json', 'node'],

  moduleDirectories: ['node_modules', 'src'],

  moduleNameMapper: {
    '^@/(.*)$': '<rootDir>/src/$1',
    '\\.(css|scss)$': 'identity-obj-proxy',
    // 添加对 Ant Design 的映射
    '^antd/es/(.*)$': 'antd/lib/$1',
  },

  collectCoverageFrom: ['src/**/*.{js,jsx}', '!src/**/*.test.{js,jsx}'],
  coverageReporters: ['html', 'text-summary'],

  transform: {
    '^.+\\.(js|jsx|ts|tsx)$': 'babel-jest',
  },

  // 确保 Ant Design 和其他可能使用 ES 模块的包被转换
  transformIgnorePatterns: ['node_modules/(?!(axios|@adobe/css-tools|antd|@ant-design|rc-.*)/)'],

  setupFilesAfterEnv: ['@testing-library/jest-dom/extend-expect'],

  testEnvironmentOptions: {
    url: 'http://localhost',
  },

  globals: {
    'process.env.NODE_ENV': 'test',
  },
};
